import { BASE_URL } from '@/config';
import { request } from '@/utils/request';

/**
 * 投诉相关接口
 */

// 查询"我的投诉"列表
export function getMyComplaints(customerId: number) {
  return request({
    url: `${BASE_URL}/user/complaints/myComplaints/${customerId}`,
    method: 'GET'
  });
}

// 获取投诉详情
export function getComplaintDetail(customerId: number, complaintId: number) {
  return request({
    url: `${BASE_URL}/user/complaints/${customerId}/complaint/detail/${complaintId}`,
    method: 'GET'
  });
}

// 提交投诉
export interface SubmitComplaintRequest {
  orderId: number;
  merchantId: number;
  type: number;
  content: string;
  evidence?: string;
}

export function submitComplaint(customerId: number, data: SubmitComplaintRequest) {
  return request({
    url: `${BASE_URL}/user/complaints/${customerId}/submit`,
    method: 'POST',
    data
  });
}

// 撤销投诉
export function cancelComplaint(customerId: number, complaintId: number) {
  return request({
    url: `${BASE_URL}/user/complaints/${customerId}/cancel/${complaintId}`,
    method: 'POST'
  });
}